/**
 * 来源：http://m.jb51.net/?src=http://www.jb51.net/article/27830.htm
 */
var returnurl = ''; 
var messagebox_timer; 
$.fn.messagebox = function (message, url, type, delay) { 
clearTimeout(messagebox_timer); 
$("#msgprint").remove(); 
var m_body = $(this); 
delay = (typeof delay == "undefined" ? 5000 : delay); 
returnurl = url; 
var box_style = 'position:absolute;display:none;z-index:1000;padding:10px 30px 10px 40px;'; 
switch (type) { 
case 1: box_style += 'border:1px solid Green;color:#090;background:url(images/msg-ok.png) 10px 10px no-repeat #F1FEF2;'; break; 
case 0: box_style += 'border:1px solid Red;color:#EE1010;background:url(images/msg-error.png) 10px 10px no-repeat #FDF8E8;'; break; 
case 2: box_style += 'border:1px solid Orange;color:Orange;background:url(images/msg-warning.png) 10px 10px no-repeat #FEFDE9;'; break; 
default: box_style += 'border:1px solid Orange;color:Orange;background:url(images/msg-info.png) 10px 10px no-repeat #FEFDE9;'; break 
} 
var str = "<div id=\"msgprint\" style=\"" + box_style + "\">" + message + "</div>"; 
$('body').append(str);
var dom_obj = document.getElementById("msgprint"); 
var ext_width = $("#msgprint").width(); 
dom_obj.style.top = "0px";//(document.documentElement.scrollTop + (document.documentElement.clientHeight - dom_obj.offsetHeight - $("#msgprint").height()) / 2) + "px"; 
dom_obj.style.left = (document.documentElement.scrollLeft + (document.documentElement.clientWidth - dom_obj.offsetWidth - $("#msgprint").width()) / 2) + "px"; 
$("#msgprint").fadeIn(1000, function () { messagebox_timer = setTimeout(messagebox_out, delay) }); 
}; 
function messagebox_out() { 
if (returnurl == undefined || returnurl == '') { $("#msgprint").fadeOut(1000) } 
if (returnurl == "back") { this.history.back(-1) } else if (returnurl != "" && returnurl != undefined) { this.location.href = returnurl } 
}; 
$('body').append("<div id='messagebox'></div>");
messagebox = {
	id: '#messagebox',
	alert : function(type, msg) {
		var _id = this.id;
		arguments = arguments || {};
		var len = arguments.length;
		if(len == 1) msg = type;
		type = type || 'success';
		if(type == "success") {
			$(_id).messagebox('成功<br/>' + msg, '', 1, 1500);
		} else if(type == "fails") {
			$(_id).messagebox('失败<br/>' + msg, '', 0, 1500);
		} else if(type == "warning") {
			$(_id).messagebox('警告<br/>' + msg, '', 2, 1500);
		} else {
			$(_id).messagebox('提示<br/>' + msg, '', 3, 1500);
		}
	}
}